// #include <iostream>
// using namespace std;

// // 定义AGX套件类
// class AGX {
// public:
//     string model;        // 型号
//     int aiPerformance;        // AI性能
//     int cudaCores;            // CUDA核心数
//     int tensorCores;          // Tensor核心数
//     int memory;               // 显存
//     int storage;              // 存储

//     // 默认构造函数
//     AGX()
//         : model("Unknown"), aiPerformance(0), cudaCores(0), tensorCores(0),
//           memory(0), storage(0) {}

//     AGX(string m, int ai, int cc, int tc, int mem, int stor)
//         : model(m), aiPerformance(ai), cudaCores(cc), tensorCores(tc), memory(mem), storage(stor) {}
// };

#pragma once 
#include <iostream>
#include <fstream> // 包含文件流头文件，用于文件操作
using namespace std;

// 定义AGX套件类
class AGX {
public:
    string model;        // 型号
    int aiPerformance;        // AI性能
    int cudaCores;            // CUDA核心数
    int tensorCores;          // Tensor核心数
    int memory;               // 显存
    int storage;              // 存储

    // 默认构造函数
    AGX()
        : model("Unknown"), aiPerformance(0), cudaCores(0), tensorCores(0),
          memory(0), storage(0) {}

    // 构造函数
    AGX(string m, int ai, int cc, int tc, int mem, int stor)
        : model(m), aiPerformance(ai), cudaCores(cc), tensorCores(tc), memory(mem), storage(stor) {}

    // 各属性的set方法
    void setModel(string newModel) {
        model = newModel;
    }

    void setAIPerformance(int newAIPerformance) {
        aiPerformance = newAIPerformance;
    }

    void setCudaCores(int newCudaCores) {
        cudaCores = newCudaCores;
    }

    void setTensorCores(int newTensorCores) {
        tensorCores = newTensorCores;
    }

    void setMemory(int newMemory) {
        memory = newMemory;
    }

    void setStorage(int newStorage) {
        storage = newStorage;
    }

    // 打印AGX套件信息
    void print() {
        cout << "AGX套件型号: " << model << endl;
        cout << "AI性能: " << aiPerformance << " TOPS" << endl;
        cout << "CUDA核心数: " << cudaCores << endl;
        cout << "Tensor核心数: " << tensorCores << endl;
        cout << "显存: " << memory << "GB" << endl;
        cout << "存储: " << storage << "GB" << endl;
    }

    // 保存AGX套件信息到本地文件
    void save(const string &filename) {
        ofstream outFile(filename, ios::app);  // 以追加模式打开文件
        if (!outFile.is_open()) {
            cerr << "无法打开文件 " << filename << endl;
            return;
        }
        outFile << "AGX套件型号: " << model << endl;
        outFile << "AI性能: " << aiPerformance << " TOPS" << endl;
        outFile << "CUDA核心数: " << cudaCores << endl;
        outFile << "Tensor核心数: " << tensorCores << endl;
        outFile << "显存: " << memory << "GB" << endl;
        outFile << "存储: " << storage << "GB" << endl;
        outFile.close();  // 关闭文件流
    }
};